forge viewer的版面主要分成上方的nav-bar,下方左欄與右欄,以及透過按鈕觸發的modal,主要皆以boostrap佈局
首先打開index.html
這個檔案,在標籤內填上下述內容
使用navbar元件,內部的logo元素靠左
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<ul class="nav navbar-nav left">
<li>
<a href="http://developer.autodesk.com" target="_blank">
<img alt="Autodesk Forge" src="//developer.static.autodesk.com/images/logo_forge-2-line.png" height="20">
</a>
</li>
</ul>
</div>
</nav>
主要欄位以boostrap的grid system佈局,首先外層以container
包住所有元素,加上fluid指定container會完整打滿整個視窗畫面。
col-sm-4
與col-sm-8
分別指定了容器樹與viewer的畫面比例。data-toggle="modal"
與 data-target="#createBucketModal"
用於觸發modal的顯示與否<div class="container-fluid fill">
<div class="row fill">
<div class="col-sm-4 fill">
<div class="panel panel-default fill">
<div class="panel-heading" data-toggle="tooltip">
Buckets & Objects
<span id="refreshBuckets" class="glyphicon glyphicon-refresh" style="cursor: pointer"></span>
<button class="btn btn-xs btn-info" style="float: right" id="showFormCreateBucket" data-toggle="modal" data-target="#createBucketModal">
<span class="glyphicon glyphicon-folder-close"></span> New bucket
</button>
</div>
<div id="appBuckets">
tree here
</div>
</div>
</div>
<div class="col-sm-8 fill">
<div id="forgeViewer"></div>
</div>
</div>
</div>
<form id="uploadFile" method='post' enctype="multipart/form-data">
<input id="hiddenUploadField" type="file" name="theFile" style="visibility:hidden" />
</form>
這個modal對應於content中的button(id="showFormCreateBucket")
<div class="modal fade" id="createBucketModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Cancel">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Create new bucket</h4>
</div>
<div class="modal-body">
<input type="text" id="newBucketKey" class="form-control"> For demonstration purposes, objects (files)
are NOT automatically translated. After you upload, right click on
the object and select "Translate". Note: Technically your bucket name is required to be globally unique across
the entire platform - to keep things simple with this tutorial your client ID will be prepended by default to
your bucket name and in turn masked by the UI so you only have to make sure your bucket name is unique within
your current Forge app.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="createNewBucket">Go ahead, create the bucket</button>
</div>
</div>
</div>
</div>
整個viewer的網頁結構完成至此。